package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Black1;
import com.ruoyi.system.service.IBlack1Service;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 黑名单管理Controller
 * 
 * @author dyl
 * @date 2023-04-17
 */
@Controller
@RequestMapping("/system/black")
public class Black1Controller extends BaseController
{
    private String prefix = "system/black";

    @Autowired
    private IBlack1Service black1Service;

    @RequiresPermissions("system:black:view")
    @GetMapping()
    public String black()
    {
        return prefix + "/black";
    }

    /**
     * 查询黑名单管理列表
     */
    @RequiresPermissions("system:black:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Black1 black1)
    {
        startPage();
        List<Black1> list = black1Service.selectBlack1List(black1);
        return getDataTable(list);
    }

    /**
     * 导出黑名单管理列表
     */
    @RequiresPermissions("system:black:export")
    @Log(title = "黑名单管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Black1 black1)
    {
        List<Black1> list = black1Service.selectBlack1List(black1);
        ExcelUtil<Black1> util = new ExcelUtil<Black1>(Black1.class);
        return util.exportExcel(list, "黑名单管理数据");
    }

    /**
     * 新增黑名单管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存黑名单管理
     */
    @RequiresPermissions("system:black:add")
    @Log(title = "黑名单管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Black1 black1)
    {
        return toAjax(black1Service.insertBlack1(black1));
    }

    /**
     * 修改黑名单管理
     */
    @RequiresPermissions("system:black:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Black1 black1 = black1Service.selectBlack1ById(id);
        mmap.put("black1", black1);
        return prefix + "/edit";
    }

    /**
     * 修改保存黑名单管理
     */
    @RequiresPermissions("system:black:edit")
    @Log(title = "黑名单管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Black1 black1)
    {
        return toAjax(black1Service.updateBlack1(black1));
    }

    /**
     * 删除黑名单管理
     */
    @RequiresPermissions("system:black:remove")
    @Log(title = "黑名单管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(black1Service.deleteBlack1ByIds(ids));
    }
}
